/**
 * update: 2018-10-27
 * author: xuek
 * explain: 页面滚动
 */
export const scrollDown = className => {
  var body = document.documentElement || document.body,
    bodyScroll = body.scrollTop || window.pageYOffset,
    scrollHeight = document.querySelector(className).offsetHeight,
    timer,
    unit = 30,
    scrollLen = 0;

  (() => {
    const fn = () => {
      timer = setInterval(() => {
        scrollLen += unit;
        if (scrollLen >= scrollHeight) {
          scrollLen = scrollHeight;
          clearInterval(timer);
        }
        window.scroll(0, bodyScroll + scrollLen);
      }, 17);
    };
    return fn;
  })()();
};